package com.monitor.dao;

import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.monitor.entity.ErpCarTireArchives;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 车辆轮胎档案表 Mapper 接口
 * </p>
 *
 * @author LX
 * @since 2018-09-27
 */
public interface ErpCarTireArchivesMapper extends BaseMapper<ErpCarTireArchives> {

    @Select("select * FROM erp_car_tire_archives cararchivew " +
            "   LEFT JOIN erp_tire_archives tirearchivew ON tirearchivew.tire_id=cararchivew.tire_id  " +
            "   LEFT JOIN erp_materiel materiel ON materiel.id=cararchivew.tire_id " +
            "   LEFT JOIN erp_customer_car car ON car.id=cararchivew.car_id " +
            "   LEFT JOIN erp_parameters parameters ON parameters.id=cararchivew.tire_id " +
            "  where cararchivew.car_id in(${carId})")
    List<Map<String,Object>> getTireByCarId(@Param("carId") String carId);

    @Select("select count(*) from erp_car_tire_archives c where c.car_id in (select cc.id  from erp_customer_car cc where cc.customer_id = #{custId})")
    public Integer selectByCustId(@Param("custId")int custId);
}
